﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Soft
{
    /// <summary>
    /// 结果
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class ResultData<T> : Result, IResultData<T>, IResult, IError, IResultData
    {
        public ResultData()
        {
            Type typeFromHandle = typeof(T);
            if (typeFromHandle.IsValueType)
            {
                if (typeFromHandle == typeof(string))
                {
                    this.Data = (T)((object)string.Empty);
                    return;
                }
                this.Data = default(T);
            }
        }

        public ResultData(IResult result) : base(result)
        {
        }

        public ResultData(string error) : base(error, null)
        {
        }

        public ResultData(Exception e) : base(e, null)
        {
        }


        public T Data { get; set; }


        object IResultData.Data
        {
            get
            {
                return this.Data;
            }
        }
    }
}
